#ifndef OGG_H
#define OGG_H

#include "LPC24xx.h"
#include "type.h"

	#define XRESET_HIGH()   FIO2SETL = (1 << 0)
	#define XRESET_LOW()    FIO2CLRL = (1 << 0)
	#define DREQ()			(FIO2PIN0 & (1 << 1))
    #define SET_XCS_LOW()	FIO2CLRL = (1 << 6)
	#define SET_XCS_HIGH()	FIO2SETL = (1 << 6)

	void LoadUserCode(void);
	void ProgramVLSI(void);
	void WriteVS10xxRegister(WORD addr, WORD val);
	WORD ReadVS10xxRegister(WORD addr);
	void VS1053_Init(void);
	void OGG_reset(void);
	void OGG_init(void);
	void OGG_SPI_Test(void);
	void OGG_Read_Test(void);
	void StartRecording(void);

	#define DEBUG_MODE 0

#define DONE_READING_OGG_BUFFER 2
#define OGG_NOT_DONE_FILLING_BUFFER 0
#define OGG_DONE_FILLING_BUFFER 1

	// First byte to be sent is 0x02 (write.)
	#define CMD_WRITE	0x02
	#define CMD_READ	0x03
	#define SCI_MODE    0xC000
	#define SCI_STATUS    0xC001
	#define SCI_BASS    0xC002
	#define SCI_CLOCKF    0xC003
	#define SCI_DECODE_TIME    0xC004
	#define SCI_AUDATA    0xC005
	#define SCI_WRAM    0xC006
	#define SCI_WRAMADDR    0xC007
	#define SCI_HDAT0    0xC008
	#define SCI_HDAT1    0xC009
	#define SCI_AIADDR    0xC00A
	#define SCI_VOL        0xC00B
	#define SCI_AICTRL0    0xC00C
	#define SCI_AICTRL1    0xC00D
	#define SCI_AICTRL2    0xC00E
	#define SCI_AICTRL3    0xC00F
	#define SCI_CHANGE    0xC010
	#define SER_DATA    0xC011    /* R */
	#define SER_DREQ    0xC012    /* RW, LSB controls DREQ pin */
	#define FREQCTLL    0xC013
	#define FREQCTLH    0xC014
	#define DAC_LEFT    0xC015
	#define DAC_RIGHT    0xC016
	#define GPIO_DDR    0xC017
	#define GPIO_IDATA    0xC018
	#define GPIO_ODATA    0xC019

#endif
